﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
namespace TDT_Project.classes
{
    public class cls_lop
    {
        int _STT = 0;

        public int STT
        {
            get { return _STT; }
            set { _STT = value; }
        }
        string _TenLop = "";

        public string TenLop
        {
            get { return _TenLop; }
            set { _TenLop = value; }
        }
        string _Lop_Id = "";

        public string Lop_Id
        {
            get { return _Lop_Id; }
            set { _Lop_Id = value; }
        }
        public DataSet Load_TKBieu_quoc(string lop_id, string hocky, string nienhoc)
        {
            DataSet results = new DataSet();
            SqlConnection oConnection = new SqlConnection(cls_config.ConnectionString);
            SqlCommand oCommand = new SqlCommand("Load_TKBieu_quoc", oConnection);
            oCommand.CommandType = CommandType.StoredProcedure;
            oCommand.Parameters.Add("@lop_id", SqlDbType.NVarChar).Value = lop_id;
            oCommand.Parameters.Add("@hocky", SqlDbType.NVarChar).Value = hocky;
            oCommand.Parameters.Add("@nienhoc", SqlDbType.NVarChar).Value = nienhoc;
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = oCommand;
            da.Fill(results);
            oConnection.Close();
            oConnection.Dispose();
            oConnection = null;
            return results;

        }
        public DataSet Load_gvien_lop_quoc(string nienhoc,string lop_id)
        {
            DataSet results = new DataSet();
            SqlConnection oConnection = new SqlConnection(cls_config.ConnectionString);
            SqlCommand oCommand = new SqlCommand("Load_gvien_lop_quoc", oConnection);
            oCommand.CommandType = CommandType.StoredProcedure;
            oCommand.Parameters.Add("@nienhoc", SqlDbType.NVarChar).Value = nienhoc;
            oCommand.Parameters.Add("@lop_id", SqlDbType.NVarChar).Value = lop_id;
          
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = oCommand;
            da.Fill(results);
            oConnection.Close();
            oConnection.Dispose();
            oConnection = null;
            return results;

        }
        public DataSet load_lop_combo()
        {
            DataSet results = new DataSet();
            SqlConnection oConnection = new SqlConnection(cls_config.ConnectionString);
            SqlCommand oCommand = new SqlCommand("load_lop_combo", oConnection);
            oCommand.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = oCommand;
            da.Fill(results);
            oConnection.Close();
            oConnection.Dispose();
            oConnection = null;
            return results;

        }
        public DataSet load_hocsinh_combo(string NienHoc_ID, string Lop_Id)
        {
            DataSet results = new DataSet();
            SqlConnection oConnection = new SqlConnection(cls_config.ConnectionString);
            SqlCommand oCommand = new SqlCommand("load_hocsinh_combo", oConnection);
            oCommand.CommandType = CommandType.StoredProcedure;
            oCommand.Parameters.Add("@NienHoc_ID", SqlDbType.NVarChar).Value = NienHoc_ID;
            oCommand.Parameters.Add("@Lop_Id", SqlDbType.NVarChar).Value = Lop_Id;
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = oCommand;
            da.Fill(results);
            oConnection.Close();
            oConnection.Dispose();
            oConnection = null;
            return results;
        }

        public DataSet load_dangnhap(string SoDT, string HocSinh_ID, string NienHoc_ID)
        {
            DataSet results = new DataSet();
            SqlConnection oConnection = new SqlConnection(cls_config.ConnectionString);
            SqlCommand oCommand = new SqlCommand("load_dangnhap", oConnection);
            oCommand.CommandType = CommandType.StoredProcedure;
            oCommand.Parameters.Add("@SoDT", SqlDbType.NVarChar).Value = SoDT;
            oCommand.Parameters.Add("@HocSinh_ID", SqlDbType.NVarChar).Value = HocSinh_ID;
            oCommand.Parameters.Add("@NienHoc_ID", SqlDbType.NVarChar).Value = NienHoc_ID;
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = oCommand;
            da.Fill(results);
            oConnection.Close();
            oConnection.Dispose();
            oConnection = null;
            return results;
        }

        public DataSet CheckLogin(string username, string pass,int loai)
        {
            DataSet results = new DataSet();
            SqlConnection oConnection = new SqlConnection(cls_config.ConnectionString);
            SqlCommand oCommand = new SqlCommand("load_checklogin", oConnection);
            oCommand.CommandType = CommandType.StoredProcedure;
            oCommand.Parameters.Add("@Username", SqlDbType.NVarChar).Value = username;
            oCommand.Parameters.Add("@pass", SqlDbType.NVarChar).Value = pass;
            oCommand.Parameters.Add("@loai", SqlDbType.Int).Value = loai;
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = oCommand;
            da.Fill(results);

            oConnection.Close();
            oConnection.Dispose();
            oConnection = null;
            return results;
        }
    }
}